<?php
	
	/**
	 * 获取每个栏目下的子栏目
	 * @param unknown_type $pnid
	 * @return string
	 */
	function getSubClass($pnid){
		global $db;
		$csql="select id,name,foldername from tb_column where bigclass=".$pnid;
		$subnavstr='';
		/**/	
		$rows=$db->query($csql);
		
		while ($rs=$db->fetch_array($rows)){
			$subnavstr.='<li><a href="'.$rs['foldername'].'.php?pid='.$rs['id'].'&cid=1&ps=20&isp=0">'.$rs['name'].'</a></li>';
		}	
		return $subnavstr;
	}
	function getTopNews($num,$pid){
		global $db;
		$nsql='select * from tb_news where lang=\'cn\' order by id desc';
		$rows=$db->query($nsql);
		$indNews='';
		while ($rs=$db->fetch_array($rows)){
			$indNews.='<li><a href="newsdetail.php?pid='.$pid.'&nid='.$rs['id'].'&cid=1&ps=20&isp=0" title="'.$rs['title'].'">'.$rs['title'].'</a></li>';
		}
		return  $indNews;
	}
	function subText($txt,$num){
		$temp='';
		if(strlen($txt)>$num){
			$temp=substr($txt, 0,$num).'...';
		}
		return $temp;	
	}
	function getParentId($subid,$flag){
		$sql="select class1 from ";
		if ($flag=='news')
			$sql.= ' tb_news ';
		if($flag=='product')
			$sql.=' tb_product ';
		if($flag=='img')
			$sql.=' tb_img ';
		$sql.='where class2='.$subid;
			
		$tempv=0;
		global $db;
		$row=$db->query($sql);
		while($rs=$db->fetch_array($row)){
			$tempv=$rs['class1'];
		}
		return $tempv;
	}
	function getClassName($pnid,$top){
		global $db;
		$csql="select id,name,foldername from tb_column where bigclass=".$pnid;
		$subnavstr='';
		/**/
		$rows=$db->query($csql);
		$n=1;
		while ($rs=$db->fetch_array($rows)){
			if($n<=$top){
				$subnavstr.='<li><a href="'.$rs['foldername'].'.php?pid='.$rs['id'].'&cid=1&ps=20&isp=0">'.$rs['name'].'</a></li>';
			}else{
				break;			
			}
			
			$n++;
		}
		return $subnavstr;
	}
	
	

?>